﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NoticeMasterForm.aspx.cs"
    Inherits="FX.CC.Andon.WebSite.SystemManage.NoticeMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>公告</title>
    <script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-add" id="add" onclick="add();" plain="true">添加</a>
                    <a class="mini-button" iconcls="icon-edit" id="edit" onclick="edit()" plain="true">编辑</a>
                    <a class="mini-button" iconcls="icon-remove" id="remove" onclick="remove()" plain="true">
                        删除</a> <span class="separator"></span><a class="mini-button" onclick="close()" iconcls="icon-close"
                            plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="grid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="NoticeId"
            sizelist="[10,20,50,100]" pagesize="20">
            <div property="columns">
                <div type="indexcolumn">
                </div>
                <div field="NoticeTitle" width="500px" headeralign="center" allowsort="false">
                    公告
                </div>
                <div field="InputTime" width="120px" dateformat="yyyy-MM-dd HH:mm" headeralign="center"
                    allowsort="true">
                    日期
                </div>
                <div field="Flag" width="80px" headeralign="center" allowsort="true" renderer="onRecStatusRenderer">
                    状态
                </div>
                <div field="AddUser" width="60px" headeralign="center" allowsort="true">
                    添加人
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("grid1");
        grid.setUrl("../service/SystemManageHandler.ashx?action=GetNoticeList");
        grid.load();
        function add() {
            mini.open({
                url: "SystemManage/NoticeInfoForm.aspx",
                title: "新增", width: 530, height: 335,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new" };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }

            });
        }
        function edit() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: "SystemManage/NoticeInfoForm.aspx",
                    title: "编辑", width: 530, height: 335,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", NoticeId: row.NoticeId };
                        iframe.contentWindow.SetData(data);

                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });

            } else {
                mini.alert("请选中一条记录!");
            }
        }
        function remove() {
            var row = grid.getSelected();
            if (row) {
                mini.confirm("您确定要删除？", "确定？",
                function (action) {
                    if (action == "ok") {
                        $.ajax({
                            url: "../service/SystemManageHandler.ashx?action=RemoveNotice&NoticeId=" + row.NoticeId,
                            success: function (text) {
                                grid.reload();
                            },
                            error: function () {
                            }
                        });
                    } else {
                        return false;
                    }
                });

            } else {
                mini.alert("请选中一条记录!");
            }
        }
        function onRecStatusRenderer(e) {
            //记录行状态(0:作废，1：生效)
            if (e.value == "0") { return "<span style=\"color: Red\">作废</span>"; }
            else if (e.value == "1") { return "<span style=\"color: Green\">启用</span>"; }
            else { return ""; }
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
